package com.example.lxy.controller;

import com.example.lxy.mapper.officebuildingelectricitymapper;
import com.example.lxy.pojo.officebuildingelectricity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@ResponseBody
@Controller
@CrossOrigin
@Api(value = "写字楼电费管理",tags = "写字楼电费接口模块")
public class Offcontroller {
    @Autowired
    private officebuildingelectricitymapper off;

    @ApiOperation(value = "写字楼电费表查询",notes = "查询所有")
    @PostMapping(value = "/api/listoff")
    public List<officebuildingelectricity> listoff(){
        List<officebuildingelectricity> list = off.list();
        return list;
    }

    @ApiOperation(value = "根据XID查询",notes = "根据XID查询出来的信息")
    @PostMapping(value = "/api/listupidoff")
    public officebuildingelectricity listupid(@RequestBody officebuildingelectricity office){
        officebuildingelectricity list = off.upid(office.getXid());
        return list;

    }

    @PostMapping(value = "/api/updateoff")
    @ApiOperation(value = "修改写字楼电费",notes = "根据ID查询出来的信息进行修改")
    public String update(@RequestBody officebuildingelectricity offic) {
        off.update(offic);
        return "true";
    }

    @PostMapping(value = "/api/listdate")
    @ApiOperation(value = "条件查询",notes = "根据月份，栋楼查询出来")
    public List<officebuildingelectricitymapper> listdate(@RequestBody officebuildingelectricity offic) {
        System.out.println(offic.getSearchSupplyTimeFrom());
        System.out.println(offic.getSearchSupplyTimeTo());
        System.out.println(offic.getBuilding());
        List<officebuildingelectricitymapper> lists = off.lists(offic.getSearchSupplyTimeFrom(),offic.getSearchSupplyTimeTo(),offic.getBuilding());
        System.out.println(lists);
        return lists;
    }
}
